<template>
  <div id="b_box">
    <h1>用户{{this.cardNo}}当前余额：{{this.balance}}</h1>
    <el-button type="success"
               @click="getBalance">查看最新余额</el-button>
  </div>
</template>

<script>
import { getBalance } from '../../api/balance'
export default {
  data () {
    return {
      cardNo: localStorage.getItem('cardNo'),
      balance: ''
    }
  },
  methods: {
    async getBalance () {
      let result = await getBalance(this.cardNo);
      this.balance = result.balance;
    }
  },
  created () {
    this.getBalance()
  },
}
</script>

<style lang="less" scoped>
#b_box {
  text-align: center;
}
</style>